package com.example.teaching_server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;

/**
 * 通知类型实体类
 *
 * @author Teaching Server
 * @since 1.0.0
 */
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "typeId")
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "notice_types", indexes = {
        @Index(name = "idx_notice_type_name", columnList = "type_name")
})
public class NoticeTypeEntity {

    /**
     * 类型ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "type_id")
    private Long typeId;

    /**
     * 类型名称
     */
    @NotBlank(message = "类型名称不能为空")
    @Size(max = 50, message = "类型名称长度不能超过50个字符")
    @Column(name = "type_name", nullable = false, unique = true, length = 50)
    private String typeName;

    /**
     * 类型描述
     */
    @Size(max = 200, message = "类型描述长度不能超过200个字符")
    @Column(name = "description")
    private String description;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;
}
